package com.atguigu.lease.web.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.entity.ApartmentFeeValue;
import com.atguigu.lease.web.admin.service.ApartmentFeeValueService;
import com.atguigu.lease.web.admin.mapper.ApartmentFeeValueMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
* @author liubo
* @description 针对表【apartment_fee_value(公寓&杂费关联表)】的数据库操作Service实现
* @createDate 2023-07-24 15:48:00
*/
@Service
public class ApartmentFeeValueServiceImpl extends ServiceImpl<ApartmentFeeValueMapper, ApartmentFeeValue>
    implements ApartmentFeeValueService{
    public void insertByIdsAndItemId(Long itemId, List<Long> ids) {
        if (!CollectionUtils.isEmpty(ids)) {
            List<ApartmentFeeValue> apartmentFeeValues = new ArrayList<>();
            for (Long id : ids) {
                ApartmentFeeValue apartmentFeeValue = new ApartmentFeeValue();
                apartmentFeeValue.setApartmentId(itemId);
                apartmentFeeValue.setFeeValueId(id);
                apartmentFeeValues.add(apartmentFeeValue);
            }
            this.saveBatch(apartmentFeeValues);
        }
    }
}




